package com.cssl.utils;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @Author: chen
 * @Date: 2021/11/16 14:52
 * @Desc:
 */
public class ThreadPoolUtil {
    private static ThreadPoolExecutor threadPoolExecutor;

    private ThreadPoolUtil() {
    }

    public static ThreadPoolExecutor getThreadPoll() {
        if (threadPoolExecutor == null) {
            synchronized (ThreadPoolUtil.class) {
                if (threadPoolExecutor == null) {
                    threadPoolExecutor = new ThreadPoolExecutor(
                            8,
                            16,
                            1,
                            TimeUnit.MINUTES,
                            new LinkedBlockingQueue<>());
                }
            }
        }
        return threadPoolExecutor;
    }
}
